$(function() {
    //sidebar menu
    $('#leftSideNav').metisMenu();
    //sidebar menu position
    var leftBar = $('#left_sidebar');
    $(window).on('scroll', function () {
        var winTop = $(window).scrollTop();
        if (winTop > 60) {
            leftBar.addClass('fixed');
        }else {
            leftBar.removeClass('fixed');
        }
    });

    //responsive
    $(window).bind("load resize", function() {
        //topOffset = 50;
        if (isXs()) {
            $('div.navbar-collapse').addClass('collapse');
        } else {
            $('div.navbar-collapse').removeClass('collapse');
        }
        //height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
        //height = height - topOffset;
        //if (height < 1) height = 1;
        //if (height > topOffset) {
        //    $("#page-wrapper").css("min-height", (height) + "px");
        //}
    });
});
/**
 * page width < 768
 * @returns {boolean}
 */
function isXs() {
    return getWinW() < 768;
}
/**
 * page width (767,992)
 * @returns {boolean}
 */
function isSm() {
    var w = getWinW();
    return w > 767 && w < 992;
}
/**
 * page width (991,1200)
 * @returns {boolean}
 */
function isMd() {
    var w = getWinW();
    return w > 991 && w < 1200;
}
/**
 * page width >1199
 * @returns {boolean}
 */
function isLg() {
    var w = getWinW();
    return w > 1199;
}

function getWinW() {
    return (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
}